#include <iostream>
#include <stdio.h>
#include <string.h>
#define max 139544
//#include <math.h>
using namespace std;

double ans[max+2]; // 1M

int main()
{
	int i,j,a,b;
	int now, add;
	int tot;
	now = 0;
	add = 1;
	tot =0;
 	for (i=1; ans[tot]<=3e9; i+=2)
 	{
 	    tot+=2;
 	    ans[i] = ans[i-1] + add;
 	    ans[i+1] = ans[i] + add;
 	    add ++;
 	}    
 	int n;
 	double cha;
 	scanf("%d", &n);
 	while (n-->0)
 	{
 	    scanf("%d%d", &a, &b);
 	    cha = b-a;
 	    i=0;
 	    while (cha > ans[i])   	i++;
 	    printf("%d\n", i);
 	}    
 
    
    return 0;
}    


